<?php
    namespace app\admin\model;
    use think\Model;
    use think\Db;
    
//  model 类
    class LoginModel extends Model
    {
        // 登录验证
        public function checkoutLoginInfo($name='',$password=''){
            if(!$name || !$password){
                return false;
            }


            $password=AdminModel::encryptPassword($password);
            
            $res=Db('admin')->where(['admin_name'=>$name])->find();
            if($res && $res['password'] == $password){
                
                return $res;
            }else{
                return false;
            }

        }

        // 更新登录信息
        public function updateLoginInfo($admin_id){
            $data['login_time'] = time();
            $data['login_ip']=request()->ip();

            Db('admin')->where('admin_id',$admin_id)->update($data);

        }

       
        
        

        

    }

